#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 1e5 + 10;

LL n, m;
LL q[N], f[N], num[N];

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    num[0] = 0;
    for(int i = 1; i < N; i ++) num[i] = num[i - 1] + 1;

    cin >> n >> m;
    for(int i = 1; i <= n; i ++) cin >> q[i];

    f[1] = 1;
    for(int i = 1; i <= n; i ++){
        if(i == 1) continue;

        if(q[i] == q[i - 1]){
            f[i] = f[i - 1] + 1;
        }else{
            f[i] = f[i - 1] + num[i - 1] + 1;
        }
    }

    LL res = 0;

    for(int i = 1; i <= n; i ++) res = res + f[i];
    // cout << res << '\n';

    int opi, opx;
    while(m --){
        cin >> opi >> opx;

        if(opi == 1){
           if(q[opi] == q[opi + 1] && q[opi + 1] != opx){
                res += num[opi] * (n - opi);
            }

            if(q[opi] != q[opi + 1] && q[opi + 1] == opx){
                res -= num[opi] * (n - opi);
            }
        }else if(opi == n){
          if(q[opi] == q[opi - 1] && q[opi - 1] != opx){
                res += num[opi - 1] * (n - opi + 1);
            }

            if(q[opi] != q[opi - 1] && q[opi - 1] == opx){
                res -= num[opi - 1] * (n - opi + 1);
            }
        }else{
            if(q[opi] == q[opi + 1] && q[opi + 1] != opx){
                res += num[opi] * (n - opi);
            }

            if(q[opi] != q[opi + 1] && q[opi + 1] == opx){
                res -= num[opi] * (n - opi);
            }

            if(q[opi] == q[opi - 1] && q[opi - 1] != opx){
                res += num[opi - 1] * (n - opi + 1);
            }

            if(q[opi] != q[opi - 1] && q[opi - 1] == opx){
                res -= num[opi - 1] * (n - opi + 1);
            }
        }

        cout << res << '\n';
        q[opi] = opx;
    }




    return 0;
}